package com.woniuxy02;

import java.util.Scanner;

public class Test044 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("运算数1");
        int numA = scanner.nextInt();
        System.out.println("运算数2");
        int numB = scanner.nextInt();
        System.out.println("运算符号+-*/");
        String operator = scanner.next();
        //运算符有效true
        boolean operatorFlag = true;
        //除数0，true
        boolean divideZeroFlat=false;
        int result = 0;
        switch (operator) {
            case "+":
                result=numA+numB;
                break;
            case "-":
                result=numA-numB;
                break;
            case "*":
                result=numA*numB;
                break;
            case "/":
                if (numB!=0) {
                    result=numA/numB;
                }else{
                    divideZeroFlat=true;
                }
                break;
            default:
                operatorFlag=false;
                break;
        }

//        if (operator.equals("+")||operator.equals("-")||operator.equals("*")||(operator.equals("/")&&numB!=0)) {
//            System.out.println(numA+operator+numB+"="+result);
//        }else if((operator.equals("/")&&numB==0)){
//            System.out.println("not zero");
//        }else{
//            System.out.println("计算符错误");
//        }

        if (operatorFlag&&!divideZeroFlat) {
            System.out.println(numA+operator+numB+"="+result);
        }else if(divideZeroFlat){
            System.out.println("not zero");
        }else{
            System.out.println("计算符错误");
        }
    }
}
